<?php
require('../qcubed.inc.php');

class SampleDialogBox extends QDialogBox {
  public $txtBox;
  public $btnBox;
  public $pnlContent;

  public function __construct($objParentObject, $strControlId = null) {
    parent::__construct($objParentObject, $strControlId);
    $this->strTemplate = 'SampleDialogBox.tpl.php';
    // initially hide
    $this->blnDisplay = false;
    $this->strWidth = 800;
    $this->strHeight = 200;
    $this->strMatteColor = '#111111';
    $this->strBackColor = '#FFFFFF';

  }
}

class SampleForm extends QForm {
  public $dlgSample;
  public $lnkSample;

  protected $intCnt = 0;
  protected $intVer = 5;


  protected function Form_Create() {
    $this->dlgSample = new SampleDialogBox($this);

    $this->lnkSample = new QLinkButton($this);
    $this->lnkSample->Text = 'Clickme';
    $this->lnkSample->AddAction(new QClickEvent(), new QAjaxAction('lnkSample_Click'));
  }

  public function btn_Click(){
      $this->dlgSample->txtBox->Text = "Text Change ". $this->intCnt ++;
      $this->dlgSample->pnlContent->Text = 'Qpanel here. Click count: ' . $this->intCnt;
      //$this->dlgSample->Refresh();
  }

  public function lnkSample_Click() {
    // clicked, let's show content in dialog box
    $this->intCnt ++;
    // remember to set dialog box as parent!
    $pnl = new QPanel($this->dlgSample);
    $pnl->Text = 'Qpanel here. Click count: ' . $this->intCnt;

    $txtBox = new QTextBox($this->dlgSample);
    $txtBox->Name = "Adham";
    $txtBox->Text = "TAdham";

    $btnBox = new QLinkButton($this->dlgSample);
    $btnBox->Text = 'Button';
    $btnBox->AddAction(new QClickEvent(), new QAjaxAction('btn_Click'));

  

    $this->dlgSample->pnlContent = $pnl;
    $this->dlgSample->txtBox = $txtBox;
    $this->dlgSample->btnBox = $btnBox;


    // we need to refresh dialog box, so that new content (from QPanel) will be reloaded
    $this->dlgSample->Refresh();
    // let's show dialog box
    
    $this->dlgSample->ShowDialogBox();
  }
}

SampleForm::Run('SampleForm', 'index.tpl.php');
?>